package com.ztgf.shopping.api.client.epg;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgNoticeBO;
import com.ztgf.shopping.models.dto.epg.EpgNoticeDTO;
import com.ztgf.shopping.models.service.epg.IEpgNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 频道栏目控制器
 *
 * @author YUE
 * @create 2020-05-18 11:36
 */

@RestController
@RequestMapping("/api/epgNotice")
@Slf4j
@Api(value = "EpgNoticeApiController",tags = "公告消息Api接口")
public class EpgNoticeApiController {

    @DubboReference
    private IEpgNoticeService iEpgNoticeService;


    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<EpgNoticeDTO> get(Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }
        EpgNoticeDTO epgNoticeDTO = iEpgNoticeService.selectById(id);
        return new Result<>(epgNoticeDTO);
    }

    @ApiOperation(value = "公告消息列表",notes = "公告消息列表")
    @PostMapping("/queryPageList")
    public Result<Page<EpgNoticeDTO>> queryPageList(EpgNoticeBO epgNoticeBO){
        Page<EpgNoticeDTO> epgNoticeDTOPage = iEpgNoticeService.getBySelectNoticeInfoPage(epgNoticeBO);
        return new Result<>(epgNoticeDTOPage);
    }
}
